# 练习 3：编写一个装饰器，用于记录函数的执行时间。

import time


def timer(func):
    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        end_time = time.time()
        print(
            f"Function {func.__name__} took {end_time - start_time:.6f} seconds to execute."
        )
        return result

    return wrapper


@timer
def slow_function():
    time.sleep(2)
    return "Done"


print(slow_function())
